package com.example.jh352160.surfingtv.category.customView.adapter;

import android.view.View;
import android.view.ViewGroup;

import com.example.jh352160.surfingtv.category.customView.CategoryList;

import java.util.List;

/**
 * Created by jh352160 on 2016/7/25.
 */

public class PagerAdapter extends android.support.v4.view.PagerAdapter {

    private List<CategoryList> categoryLists;

    public PagerAdapter(List<CategoryList> categoryLists) {
        this.categoryLists = categoryLists;
    }

    @Override
    public int getCount() {
        return categoryLists.size();
    }

    @Override
    public boolean isViewFromObject(View view, Object object) {
        return view == object;
    }

    @Override
    public Object instantiateItem(ViewGroup container, int position) {
        container.addView(categoryLists.get(position));
        return categoryLists.get(position);
    }

    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {
        container.removeView(categoryLists.get(position));
    }
}
